// 导入路由组件
import { createRouter, createWebHistory } from 'vue-router';

// 导入组件
import Login from '@/views/Login.vue';
import Layout from '@/views/Layout.vue';
import ToDoManage from '@/views/todo/ToDoManage.vue';
import Setting from '@/views/setting/Setting.vue';

// 定义路由规则
const routes = [
  { path: '/login', component: Login },
  {
    path: '/home', component: Layout, redirect: '/home/todo', children: [
      { path: '/home/todo', component: ToDoManage },
      { path: '/home/setting', component: Setting },
    ],
  },
  { path: '/', redirect: '/login' },
];

// 创建路由器
const router = createRouter({
  // 使用 HTML5 History 模式
  history: createWebHistory(),
  // 路由规则
  routes,
});

// 导出路由器
export default router;
